home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / URL Helper II / Source / URLHelperComponent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-14  |  3.3 KB  |  138 lines  |  [TEXT/MMCC]

  1. /***
  2.  * URLHelperComponent.h
  3.  *
  4.  *  Header file for the URL Helper
  5.  *
  6.  ***/
  7.  
  8. #pragma once
  9.  
  10. /**
  11.  ** The component type
  12.  **/
  13.  
  14. #define URLHelperComponentType    'URLh'
  15.  
  16. /**
  17.  ** Errors
  18.  **/
  19.  
  20. enum {
  21.     errURLHNoSuchMirrorList = -2200,            // No such mirror list found
  22.     errURLHNoMirrorMatch = -2201,                // No mirror matched that URL
  23.     errURLHNameEndsWithReplChar = -2202,        // Mirror name ends with a "^"!
  24.     errURLHTooManyReplacements = -2203,            // Too many replacement "^"s
  25.     errURLHBadReplChar = -2204,                    // Bad char after "^"
  26.     errURLHNoUsableMirror = -2205                // index was too large -- end of list!
  27.  
  28. };
  29.  
  30. /**
  31.  ** Global types
  32.  **/
  33. typedef long URLHMirrorFlags;
  34. typedef long URLHMirrorListRef;
  35. typedef long URLHParseRef;
  36. typedef    long URLHMirrorRef;
  37.  
  38. /**
  39.  ** Flags for a mirror
  40.  **/
  41.  
  42. enum {
  43.     kURLHMDefault        = 0,        // default mirror usage.
  44.     kURLHMNoUse            = 1            // Don't use this in replacement.
  45. };
  46.  
  47. /**
  48.  ** The component request codes -- the functions we are going to be running
  49.  **/
  50.  
  51. enum {
  52.     kDoGetMirrorList        = 1,
  53.     kDoNewMirrorList        = 2,
  54.     kDoAddMirror            = 3,
  55.     kDoNumberOfMirrors        = 4,
  56.     kDoGetUsableMirror        = 5,
  57.  
  58.     kDoNewParseState        = 20,
  59.     kDoDisposeParseState    = 21,
  60.     kDoGetMirrorRep            = 22
  61. };
  62.  
  63. /**
  64.  ** The component instance for all to use
  65.  **/
  66.  
  67. typedef ComponentInstance    URLHelperComponent;
  68.  
  69. /**
  70.  ** Mirror list stuff
  71.  **
  72.  ** GetMirrorList -- return ref to a mirror list
  73.  ** NewMirrorList -- Create a new mirror list
  74.  ** AddMirror -- add a mirror to a mirror list
  75.  ** NumberOfMirrors -- return the number of mirrors in the list that
  76.  **                        are good to use
  77.  ** GetUsableMirror -- Return pointer to a mirror that is usable
  78.  **/
  79.  
  80. pascal ComponentResult URLHGetMirrorList (
  81.                         URLHelperComponent    urlInstance,
  82.                         StringPtr            string,
  83.                         URLHMirrorListRef    *ref)
  84.         ComponentCallNow (kDoGetMirrorList, 0x08);
  85.  
  86. pascal ComponentResult URLHNewMirrorList (
  87.                         URLHelperComponent    urlInstance,
  88.                         StringPtr            string,
  89.                         URLHMirrorListRef    *ref)
  90.         ComponentCallNow (kDoNewMirrorList, 0x08);
  91.  
  92. pascal ComponentResult URLHAddMirror (
  93.                         URLHelperComponent    urlInstance,
  94.                         URLHMirrorListRef    ref,
  95.                         StringPtr            mirrorName,
  96.                         URLHMirrorFlags        flags)
  97.         ComponentCallNow (kDoAddMirror, 0x0C);
  98.  
  99. pascal ComponentResult URLHNumberOfMirrors (
  100.                         URLHelperComponent    urlInstance,
  101.                         URLHMirrorListRef    ref,
  102.                         short                *num)
  103.         ComponentCallNow (kDoNumberOfMirrors, 0x08);
  104.  
  105. pascal ComponentResult URLHGetUsableMirror (
  106.                         URLHelperComponent    urlInstace,
  107.                         URLHMirrorListRef    mirrorListRef,
  108.                         URLHMirrorRef        *mirrorRef,
  109.                         short                index)
  110.         ComponentCallNow (kDoGetUsableMirror, 0x0A);
  111.  
  112. /**
  113.  ** Parse Stuff
  114.  **
  115.  ** URLHNewParseState -- Given a URL, find a match in our lists...
  116.  ** URLHDisposeParseState -- Release the memory
  117.  ** URLHGetMirrorRep -- Make a new URL for the indexed mirror.
  118.  **/
  119.  
  120. pascal ComponentResult URLHNewParseState (
  121.                         URLHelperComponent    urlInstance,
  122.                         StringPtr            aURL,
  123.                         URLHParseRef        *ref)
  124.         ComponentCallNow (kDoNewParseState, 0x08);
  125.  
  126. pascal ComponentResult URLHDisposeParseState (
  127.                         URLHelperComponent    urlInstance,
  128.                         URLHParseRef        ref)
  129.         ComponentCallNow (kDoDisposeParseState, 0x04);
  130.  
  131. pascal ComponentResult URLHGetMirrorRep (
  132.                         URLHelperComponent    urlInstance,
  133.                         URLHParseRef        ref,
  134.                         StringPtr            newUrl,
  135.                         short                mirrorIndex)
  136.         ComponentCallNow (kDoGetMirrorRep, 0x0A);
  137.  
  138.